package model

import "admin100/app/model/internal"

type MyadminMenu internal.MyadminMenu

// func (m *MyadminMenu) ConvtoINodeArr() (iNodes []menutree.INode) {
// 	for _, v := range m {
// 		iNodes = append(iNodes, m)
// 	}
// }

type MyadminMenuNode struct {
	Id       uint   `json:"id"`
	Name     string `json:"name"`
	Title    string `json:"title"`
	ParentId uint   `json:"parentId"`
	Seq      uint   `json:"seq"`
	IsShow   uint   `json:"isShow"`
	Icon     string `json:"icon"`
}

func (m *MyadminMenuNode) GetTitle() string {
	return m.Name
}
func (m *MyadminMenuNode) GetId() int {
	return int(m.Id)
}
func (m *MyadminMenuNode) GetFatherId() int {
	return int(m.ParentId)
}
func (m *MyadminMenuNode) GetData() interface{} {
	return m
}
func (m *MyadminMenuNode) IsRoot() bool {
	return m.ParentId == 0 || m.ParentId == m.Id
}

type MyadminMenuAddReq struct {
	Name     string `v:"required#标识不能为空"`
	Title    string `v:"required#标题不能为空"`
	ParentId int
	Seq      int
	IsShow   int `v:"max:1#是否显示只能为0或1"`
	Icon     string
}

type MyadminMenuEditReq struct {
	Id       string `v:"required#菜单ID不能为空"`
	Name     string `v:"required#标识不能为空"`
	Title    string `v:"required#标题不能为空"`
	ParentId int
	Seq      int
	IsShow   int `v:"max:1#是否显示只能为0或1"`
	Icon     string
}

type MyadminMenuIdReq struct {
	Id int64
}
